﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class Account_ViewGroup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Page_Init(object sender, EventArgs e)
    {

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
        SqlCommand cmd;
        SqlDataReader reader;

        if (!string.IsNullOrEmpty(Request.QueryString["id"]))
        {
            try
            {
                conn.Open();

                cmd = new SqlCommand("SELECT name FROM [Group] WHERE id=@id AND Status=1", conn);
                cmd.Parameters.AddWithValue("@id", Request.QueryString["id"]);
                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Panel1.GroupingText = (string)reader["name"];
                    }
                }
                else
                {
                    Response.Redirect("~/Account/Group.aspx");
                }
                reader.Close();






            }
            finally
            {
                conn.Close();

            }
        }
        else
        {
            Response.Redirect("~/Account/Group.aspx");
        }
        SqlDataSource1.InsertParameters["UserName"].DefaultValue = User.Identity.Name;
        SqlDataSource1.InsertParameters["Date"].DefaultValue = DateTime.Now.ToString();
    }
  
}